<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;


class BatchSetController extends Controller{


    //批量发布  取消发布
    public function releaseAll(){

        if(isset($_POST['ids']) && $_POST['ids'] && isset($_POST['type'])){

            if($_POST['type'] == 1){//批量发布
                $res = DB::table('zm_video_list')->whereIn('id',$_POST['ids'])->update(['show_state'=>1,'release_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')]);
            }else{//取消发布
                $res = DB::table('zm_video_list')->whereIn('id',$_POST['ids'])->update(['show_state'=>0,'updated_at'=>date('Y-m-d H:i:s')]);
            }

            if($res){
                return $this->json(1,'操作成功','');
            }else{
                return $this->json(1,'操作失败','');
            }
        }else{

            return $this->json(1,'请选择要处理的行！','');
        }

    }

    //发布操作
    public function release(){

        if(isset($_POST['ids']) && $_POST['ids']){
            $res = DB::table('zm_video_list')->where('id',$_POST['ids'])->update(['show_state'=>1,'release_at'=>date('Y-m-d H:i:s')]);
            if($res){
                return json_encode(['state'=>1,'msg'=>'发布成功!']);
            }else{
                return json_encode(['state'=>0,'msg'=>'发布失败!']);
            }
        }else{
            return json_encode(['state'=>0,'msg'=>'参数错误!']);
        }
    }


















}
